from django.db import models

# Create your models here.

class Author(models.Model):
    username = models.CharField(max_length=100)
    password = models.CharField(max_length=200)
    type1 = models.IntegerField()
    class Meta:
        db_table='author'

class Books(models.Model):
    name = models.CharField(max_length=100)
    author = models.ForeignKey(Author,on_delete=models.CASCADE)
    class Meta:
        db_table='books'




#第二个
class User(models.Model):
    username = models.CharField(max_length=100)
    password = models.CharField(max_length=200)
    type2 = models.IntegerField(verbose_name='等级')
    jifen = models.IntegerField(default=0)
    class Meta:
        db_table='user'
        verbose_name='用户名'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.username



class Shops(models.Model):
    name = models.CharField(max_length=100)
    price = models.DecimalField(max_digits=7,decimal_places=2)
    class Meta:
        db_table = 'shops'
        verbose_name = '商品表'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.name

class Content(models.Model):
    content = models.TextField(default='')
    user = models.ForeignKey(User,on_delete=models.CASCADE)
    shop = models.ForeignKey(Shops,on_delete=models.CASCADE)



